class Solution {
public:
    int pivotIndex(vector<int>& nums) {

        int sum_left = 0;
        int sum = 0;

        if(nums.size() == 0)
            return -1;
        
        for(int i = 0; i < nums.size(); i++)
        {
            sum = sum + nums[i];
        }

        for(int j = 0; j < nums.size(); j++)
        {  
            
            if(sum_left * 2 + nums[j] == sum)
            {
                return j;
                break;
            }
            else 
                sum_left += nums[j];          
        }
        
        return -1;

    }
};

// The same question, the different answer